package com.ardf.controller;

import com.ardf.entity.Unit;
import com.ardf.service.IUnitService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ShiYunHao
 * @since 2025-01-06
 */
@RestController
@RequestMapping("/ardf/unit")
public class UnitController {
    private final IUnitService unitService;

    public UnitController(IUnitService unitService){
        this.unitService=unitService;
    }
    /**
     * 根据赛事id查询单位
     */
    @GetMapping("/getByCompetitionId")
    public ResponseEntity<List<Unit>> getByCompetitionId(@RequestParam("competitionId") Long competitionId){
        List<Unit> units = unitService.list(new LambdaQueryWrapper<Unit>()
                .eq(Unit::getCompetitionId, competitionId));
        return ResponseEntity.ok(units);
    }
}
